<template>
  <div class="dashboard-container">
    <el-table
      ref="singleTable"
      :data="tableData"
      highlight-current-row
      style="width: 100%"
      @current-change="handleCurrentChange"
    >
      <el-table-column
        type="index"
        width="50"
      />
      <el-table-column
        prop="title"
        label="名称"
        width="200"
      />
      <el-table-column
        prop="tag"
        label="国籍"
        width="100"
        :filters="[{ text: '国内', value: '国内' }, { text: '国外', value: '国外' }]"
        :filter-method="filterTag"
        filter-placement="bottom-end"
      >
        <template slot-scope="scope">
          <el-tag
            :type="scope.row.tag === '国内' ? 'primary' : 'success'"
            disable-transitions
          >{{ scope.row.tag }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="desc"
        label="简介"
      />
      <el-table-column
        prop="date"
        label="日期"
        sortable
        width="380"
        column-key="date"
        :filters="[{text: '2016-05-01', value: '2016-05-01'}, {text: '2016-05-02', value: '2016-05-02'}, {text: '2016-05-03', value: '2016-05-03'}, {text: '2016-05-04', value: '2016-05-04'}]"
        :filter-method="filterHandler"
      />
    </el-table>
    <el-dialog
      :visible.sync="dialogVisible"
      width="80%"
    >
      <book-list></book-list>
    </el-dialog>
  </div>
</template>

<script>
import BookList from '@/views/list/bookList'
export default {
  components: { BookList },
  data() {
    return {
      dialogVisible: false,
      tableData: [{
        title: '王小虎',
        desc: '上海市普陀区金沙江路 1518 弄',
        tag: '国内',
        date: '2016-05-02'
      }, {
        title: '王小虎',
        desc: '上海市普陀区金沙江路 1518 弄',
        tag: '国内',
        date: '2016-05-02'
      }, {
        title: '王小虎',
        desc: '上海市普陀区金沙江路 1518 弄',
        tag: '国内',
        date: '2016-05-02'
      }, {
        title: '王小虎',
        desc: '上海市普陀区金沙江路 1518 弄',
        tag: '国内',
        date: '2016-05-02'
      }]
    }
  },
  methods: {
    handleCurrentChange() {
      this.dialogVisible = true
    },
    filterTag(value, row) {
      return row.tag === value
    },
    filterHandler(value, row, column) {
      const property = column['property']
      return row[property] === value
    }
  }
}
</script>
